class Solution(object):
    def countCombinations(self, pieces, positions):
        self.ans = 0
        st = []
        m = len(pieces)
        positions = [[x - 1, y - 1] for x, y in positions]
        def judge():
            index = 0
            while index < 8:
                a_set = set()
                for i, (ux, uy, t) in enumerate(st):
                    x, y = positions[i]
                    if index >= t:
                        next_x, next_y = x + t * ux, y + t * uy
                    else:
                        next_x, next_y = x + index * ux, y + index * uy
                    if (next_x, next_y) in a_set:
                        return 0
                    a_set.add((next_x, next_y))
                index += 1
            return 1
                            
        def dfs(i):
            if i == m:
                self.ans += judge()
            else:
                item = pieces[i]
                x, y = positions[i]
                if item == 'rook':
                    direction = [[0, 1], [0, -1], [1, 0], [-1, 0]]
                if item == 'queen':
                    direction = [[0, 1], [0, -1], [1, 0], [-1, 0], [1, 1], [1, -1], [-1, 1], [-1, -1]]
                if item == 'bishop':
                    direction = [[1, 1], [1, -1], [-1, 1], [-1, -1]]
                st.append((0, 0, 0))
                dfs(i + 1)
                st.pop()
                for ux, uy in direction:
                    index = 1
                    while 0 <= x + index * ux < 8 and 0 <= y + index * uy < 8:
                        st.append((ux, uy, index))
                        dfs(i + 1)
                        st.pop()
                        index += 1
        dfs(0)
        return self.ans



        
data = Solution()
pieces = ["rook","rook"]
positions = [[1,1],[8,8]]
print(data.countCombinations(pieces, positions))